from typing import Optional

from ninja import FilterSchema, Schema, Field

from apps.manager.user_manager.serializers import ModelSerializer
from models.models import GoodType


class ManagerGoodsFiltersSchema(FilterSchema):
    """商品筛选"""
    name: Optional[str] = Field(None, description="名称", q="name__contains")
    type: Optional[int] = Field(None, description="商品类型", q="type__id")
    status: Optional[int] = Field(None, description="状态")


class ManagerGoodsStatusOpSchema(Schema):
    """
    商品状态操作
    """
    id: int = Field(default=0, description="id")
    status: int = Field(default=0, description="状态")


class ManagerGoodUpdateSchema(Schema):
    """
    商品
    """
    name: str = Field(default="", description="名称")
    type: int = Field(default=0, description="类型")
    status: int = Field(default=0, description="状态")
    inventory: int = Field(default=0, description="库存")
    describe: str = Field(default="", description="描述")
    specifications: str = Field(default="", description="规格")
    price: float = Field(default=0, description="价格")
    vip_price: float = Field(default=0, description="会员价格")
    normal_agent_price: float = Field(default=0, description="普通代理价格")
    regional_agent_price: float = Field(default=0, description="地区代理价格")
    province_agent_price: float = Field(default=0, description="省级代理价格")
    freight: float = Field(default=0, description="运费")
    water_droplets: int = Field(default=0, description="水滴数")
    shipping_address: str = Field(default="", description="发货地址")
    sales_number: int = Field(default=0, description="销量")
    browsers_number: int = Field(default=0, description="浏览人数")


class GoodSpecsAddSchema(Schema):
    """
    商品规格新增
    """
    title: str = Field(default="", description="标题")
    spec: str = Field(default="", description="规格")
    price: float = Field(default=0, description="价格")
    vip_price: float = Field(default=0, description="会员价")
    normal_agent_price: float = Field(default=0, description="普通代理价")
    regional_agent_price: float = Field(default=0, description="地区代理价")
    province_agent_price: float = Field(default=0, description="省级代理价")
    freight: float = Field(default=0, description="运费")
    water_droplets: int = Field(default=0, description="水滴数")
    water_cards: int = Field(default=0, description="水卡数")
    province_agency_income: float = Field(default=0, description="省级代理收入")
    regional_income: float = Field(default=0, description="地区收入")
    inventory: int = Field(default=0, description="库存")


class GoodSpecsUpdateSchema(Schema):
    """
    商品规格更新
    """
    id: int = Field(default=0, description="id")
    title: str = Field(default="", description="标题")
    spec: str = Field(default="", description="规格")
    price: float = Field(default=0, description="价格")
    vip_price: float = Field(default=0, description="会员价")
    normal_agent_price: float = Field(default=0, description="普通代理价")
    regional_agent_price: float = Field(default=0, description="地区代理价")
    province_agent_price: float = Field(default=0, description="省级代理价")
    freight: float = Field(default=0, description="运费")
    water_droplets: int = Field(default=0, description="水滴数")
    water_cards: int = Field(default=0, description="水卡数")
    province_agency_income: float = Field(default=0, description="省级代理收入")
    regional_income: float = Field(default=0, description="地区收入")
    inventory: int = Field(default=0, description="库存")


class GoodsAddSchema(Schema):
    """
    商品新增
    """
    name: str = Field(default="", description="名称")
    describe: str = Field(default="", description="描述")
    status: int = Field(default=0, description="状态")
    type_id: int = Field(default=0, description="类型")
    browsing_number: int = Field(default=0, description="浏览人数")
    sales_number: int = Field(default=0, description="销量")
    buyers_number: int = Field(default=0, description="购买人数")
    collections_number: int = Field(default=0, description="收藏人数")
    shopping_cart_number: int = Field(default=0, description="购物车人数")
    shipping_address: str = Field(default="", description="发货地址")
    specs: list[GoodSpecsAddSchema] = Field(default=[], description="规格")
    files: list[str] = Field(default=[], description="图片")


class GoodsUpdateSchema(Schema):
    """
    商品更新
    """
    name: str = Field(default="", description="名称")
    describe: str = Field(default="", description="描述")
    status: int = Field(default=0, description="状态")
    type_id: int = Field(default=0, description="类型")
    browsing_number: int = Field(default=0, description="浏览人数")
    sales_number: int = Field(default=0, description="销量")
    buyers_number: int = Field(default=0, description="购买人数")
    collections_number: int = Field(default=0, description="收藏人数")
    shopping_cart_number: int = Field(default=0, description="购物车人数")
    shipping_address: str = Field(default="", description="发货地址")
    specs: list[GoodSpecsUpdateSchema] = Field(default=[], description="规格")
    upload_files: list[str] = Field(default=[], description="图片")


class GoodTypeAddSchema(Schema):
    """
    商品类型新增
    """
    name: str = Field(default="", description="名称")
